﻿<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="kiben" content="no-cache" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href=" /favicon.ico" />
    <title>校园支付 - 用户登录</title>
    <link href="css/login.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/dialog.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.1.6.2_mini.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="js/service.js" type="text/javascript"></script>
    <script type="text/javascript">
        var defaultValues = ['学号 \\ 教职工号', '密码', '验证码'];
        
        $(function () {
            $('input:[type=text]').each(function (i) {
                var defaultValue = defaultValues[i];
                $(this).val(defaultValue).bind({
                    'focus': function () {
                        if ($(this).attr('name') != 'password') {
                            var tmpVal = $(this).val();
                            if (!tmpVal || tmpVal == defaultValue) {
                                $(this).val('').addClass('act');
                            }
                        } else {
                            var _this = $(this);
                            var realPass = $('<input />')
                            .attr({ 'class': 'act', 'name': 'userPass', 'id': 'userPass', 'type': 'password', 'maxlength': 16 })
                            .val('')
                            .blur(function () {
                                if (!$(this).val()) {
                                    $(this).remove();
                                    _this.show();
                                }
                            });
                            $(this).hide().before(realPass);
                            realPass[0].focus();
                        }
                    },
                    'blur': function () {
                        var tmpVal = $(this).val();
                        if (!tmpVal || tmpVal == defaultValue) {
                            $(this).val(defaultValue).removeClass('act');
                        }
                    }
                });
            });
            
            $('#verifyImage').click(
                function() {
                    $(this).hide().attr('src', 'verifycode.action?tick=' + Math.floor(Math.random() * 100)).fadeIn();
                }
            );

            $('#submit').click(function () {
                var _userName = $('#userName').val().replace(defaultValues[0], '').Trim();
                var _userPass = $('#userPass').val() ? $('#userPass').val().Trim() : '';
                var _verifyCode = $('#verifyCode').val().replace(defaultValues[2], '').Trim();
                var _keepLogin = !!$('#keepLogin').attr('checked');
                if (_userName == '' || _userPass == '' || _verifyCode == '') {
                    alert('登录账号、密码、验证码均不能为空！');
                } else {
                    $('#loginForm').submit();
				}

                /*var ajax = new AJAXFunction({ url: Servlet.UserLogin, param: { userName: _userName, userPass: _userPass, verifyCode: _verifyCode, keepLogin: _keepLogin} });
                ajax.SuFun = function (data) {
                    if (data.Data) {
                        window.location.href = 'index.html';
                    } else {
                        Alert(data.Message);
                        return;
                    }
                };
                ajax.SendFun();*/
            });
        });    
    </script>
</head>
<body>
    <div class="loginBox">
        <form id="loginForm" action="login!submit.action" method="post">
            <p class="logo"></p>
            <p class="line">
                <input name="userName" id="userName" type="text" value="学号 \ 教职工号" maxlength="16" />
            </p>
            <p class="line">
                <input name="password" id="password" type="text" value="密码" maxlength="16" />
            </p>
            <p class="line">
                <input name="verifyCode" id="verifyCode" type="text" value="验证码" maxlength="4" class="short" />
                <img id="verifyImage" src="verifycode.action?tick=<s:property value="tick"/>" alt="验证码" />
                <input type="submit" name="submit" id="submit" value="" class="submit" />
            </p>
            <p class="last">
                <input type="checkbox" name="keepLogin" id="keepLogin" />
                <label for="keepLogin">保持登录</label>
            </p>
        </form>    
    </div>
</body>
</html>